package com.xlisteven.fallback;

import com.xlisteven.entity.Fruits;
import com.xlisteven.feign.FruitsClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class FruitsFallback implements FallbackFactory<FruitsClient> {
    @Override
    public FruitsClient create(Throwable throwable) {
        return new FruitsClient() {
            @Override
            public List<Fruits> getFruitsList(Long userId) {
                log.info("水果开始降级处理,{}", userId);
                return null;
            }

            @Override
            public void insert(List<Fruits> fruitsList) {
                log.error("水果插入失败");
            }
        };
    }
}
